home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / renderCreateBarUI.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  34.8 KB  |  1,407 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Alias|Wavefront Script File MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  March 5, 2001
  21. //  Author:         jdc rendering
  22. //
  23.  
  24. global proc string renderCreateBarCB( 
  25.     string $as, 
  26.     string $flag,
  27.     string $type)
  28. {
  29.     //
  30.     // Description:
  31.     //    This procedure is called when the user presses one of the buttons in
  32.     //    the create bar or releases a drag and drop from one of the buttons in
  33.     //    the create bar. 
  34.     //    This procedure calls renderCreateNode() with the arguments necessary to
  35.     //    create a node of the type which corresponds to the button.
  36.     //    Input arguments to this procedure are as follows:
  37.     //
  38.     //        $as: A flag specifying which how to classify the node created.
  39.     //        Choices:
  40.     //            -as2DTexture: 2d textures
  41.     //            -as3DTexture: 3d textures
  42.     //            -asEnvTexture: Environment textures
  43.     //            -asShader: as a shader
  44.     //            -asLight: as a light
  45.     //            -asUtility: as a rendering utility node
  46.     //
  47.     //      $flag: A secondary flag used to make decisions in combination with 
  48.     //               $as.
  49.     //        Choices:
  50.     //            -asBump: defines a created texture as a bump
  51.     //            -asNoShadingGroup: for materials; create without a shading 
  52.     //                group.
  53.     //            -asDisplacement: for anything; map the created node 
  54.     //                to a displacement material.
  55.     //            -asUtility: for anything; do whatever the $as flag says,
  56.     //                but also classify as a utility
  57.     //            -asPostProcess: for any postprocess node
  58.     //
  59.     //        $type: The type of node to be created.
  60.     //
  61.     //
  62.     // Returns: 
  63.     //    The name of the created node.
  64.     //
  65.  
  66.     string $postCommand = "";
  67.     int $projection = (`optionVar -query create2dTextureType` == "projection");
  68.     int $stencil = (`optionVar -query create2dTextureType` == "stencil");
  69.     int $placement = `optionVar -query createTexturesWithPlacement`;
  70.     int $shadingGroup = `optionVar -query createMaterialsWithShadingGroup`;
  71.     int $createAndDrop = 0;
  72.     string $editor = "";
  73.  
  74.     return renderCreateNode(
  75.         $as,
  76.         $flag,
  77.         $type, 
  78.         $postCommand,
  79.         $projection,
  80.         $stencil,
  81.         $placement,
  82.         $shadingGroup,
  83.         $createAndDrop,
  84.         $editor);
  85. }
  86.  
  87. proc string smallUIName (string $nodeName)
  88. {
  89.     // In most cases we can just take the given name and
  90.     // add spaces to make it more appealing.  For a few
  91.     // larger names we will override the name with a
  92.     // shorter version.  This makes the whole window smaller.
  93.     //
  94.     string $labelName;
  95.  
  96.     switch ($nodeName) {
  97.         case "displacementShader":
  98.             $labelName = "Displacement";
  99.             break;
  100.         case "plusMinusAverage":
  101.             $labelName = "+/- Average";
  102.             break;
  103.         case "doubleShadingSwitch":
  104.             $labelName = "Double Switch";
  105.             break;
  106.         case "quadShadingSwitch":
  107.             $labelName = "Quad Switch";
  108.             break;
  109.         case "singleShadingSwitch":
  110.             $labelName = "Single Switch";
  111.             break;
  112.         case "tripleShadingSwitch":
  113.             $labelName = "Triple Switch";
  114.             break;
  115.         case "particleSamplerInfo":
  116.             $labelName = "Particle Sampler";
  117.             break;
  118.         case "surfaceLuminance":
  119.             $labelName = "Surf. Luminance";
  120.             break;
  121.         case "place2dTexture":
  122.             $labelName = "2d Placement";
  123.             break;
  124.         case "place3dTexture":
  125.             $labelName = "3d Placement";
  126.             break;
  127.         default:
  128.             $labelName = interToUI($nodeName);
  129.             break;
  130.     }    
  131.     
  132.      return $labelName;
  133. }
  134.  
  135. global proc renderCreateBarUIManage(
  136.     string $renderCreateBarUI,
  137.     int $manage)
  138. {
  139.     //
  140.     // Description:
  141.     //    This procedure is called to cause the render create bar UI to be shown
  142.     //    or hidden.
  143.     //    This procedure causes the formLayout which contains the render create
  144.     //    bar UI to be managed or unmanaged, according to the $manage argument.
  145.     //
  146.     formLayout
  147.         -edit
  148.         -manage $manage
  149.         $renderCreateBarUI;
  150. }
  151.  
  152. global proc int renderCreateBarUIIsManaged(
  153.     string $renderCreateBarUI)
  154. {
  155.     //
  156.     // Description:
  157.     //    This procedure is called to determine whether or not the create bar UI
  158.     //    is being shown.
  159.     //
  160.     // Returns: 
  161.     //    true if the render create bar UI is shown, false if not.
  162.     //
  163.  
  164.     return (`formLayout -query -manage $renderCreateBarUI`);
  165. }
  166.  
  167. proc string tabUIName(
  168.     string $tab)
  169. {
  170.     //
  171.     // Description:
  172.     //    This procedure is called whenever it is necessary to get a user
  173.     //    friendly name for one of the create bar tabs, given the name of the tab
  174.     //    itself.
  175.     //    This procedure associates a user friendly name with the tab name.
  176.     //
  177.     // Returns: 
  178.     //    The user friendly name.
  179.     //
  180.  
  181.     string $uiName = $tab;
  182.  
  183.     string $style = `optionVar -query renderCreateBarStyle`;
  184.  
  185.     if ($style == "iconsAndText")
  186.     {
  187.         if ($tab == "materialsTab")
  188.         {
  189.             $uiName = "Create Materials";
  190.         }
  191.         else if ($tab == "texturesTab")
  192.         {
  193.             $uiName = "Create Textures";
  194.         }
  195.         else if ($tab == "lightsTab")
  196.         {
  197.             $uiName = "Create Lights";
  198.         }
  199.         else if ($tab == "utilitiesTab")
  200.         {
  201.             $uiName = "Create Utilities";
  202.         }
  203.         else if ($tab == "allNodesTab")
  204.         {
  205.             $uiName = "Create All Nodes";
  206.         }
  207.         else if ($tab == "mrNodesTab")
  208.         {
  209.             $uiName = "Create mental ray Nodes";
  210.         }
  211.         else
  212.         {
  213.             // Somebody has added a new tab to the create bar but has not
  214.             // associated it with a user friendly name.
  215.             //
  216.             warning("Create bar tab does not have a corresponding UI name.");
  217.         }
  218.     }
  219.     else // ($style == "iconsAndText")
  220.     {
  221.         if ($tab == "materialsTab")
  222.         {
  223.             $uiName = "Materials";
  224.         }
  225.         else if ($tab == "texturesTab")
  226.         {
  227.             $uiName = "Textures";
  228.         }
  229.         else if ($tab == "lightsTab")
  230.         {
  231.             $uiName = "Lights";
  232.         }
  233.         else if ($tab == "utilitiesTab")
  234.         {
  235.             $uiName = "Utilities";
  236.         }
  237.         else if ($tab == "allNodesTab")
  238.         {
  239.             $uiName = "All";
  240.         }
  241.         else if($tab == "mrNodesTab")
  242.         {
  243.             $uiName = "mr Nodes";
  244.         }
  245.         else
  246.         {
  247.             // Somebody has added a new tab to the create bar but has not
  248.             // associated it with a user friendly name.
  249.             //
  250.             warning("Create bar tab does not have a corresponding UI name.");
  251.         }
  252.     }
  253.  
  254.     return $uiName;
  255. }
  256.  
  257. global proc renderCreateBarUIBuildTabChoiceMenu(
  258.     string $tabChoiceButton,
  259.     string $menu)
  260. //
  261. //    Description:
  262. //        This procedure is called whenever the user clicks on the tab choice
  263. //        button in the render create bar.
  264. //        This procedure builds the menu which appears.
  265. //
  266. //    Arguments:
  267. //        $tabChoiceButton - The button the popup menu is parented to.
  268. //
  269. //        $menu - The menu attached to the button.
  270. //
  271. {
  272.     setParent -menu $menu;
  273.     menu -edit -deleteAllItems $menu;
  274.  
  275.     string $createBarTabLayout = `setParent createBarTabLayout`;
  276.     string $currentTab = `tabLayout -query -selectTab $createBarTabLayout`; 
  277.     string $tabArray[] = `tabLayout -query -childArray $createBarTabLayout`; 
  278.  
  279.     radioMenuItemCollection;
  280.  
  281.     for ($i = 0; $i < size($tabArray); $i++)
  282.     {
  283.         // Construct the command the menu item will invoke
  284.         //
  285.         string $cmd = 
  286.             ("tabLayout -edit -selectTab " 
  287.                 + $tabArray[$i] 
  288.                 + " "
  289.                 + $createBarTabLayout
  290.                 + "; "
  291.                 + "optionVar -stringValue renderCreateBarCurrentTab "
  292.                 + $tabArray[$i]
  293.                 + "; "
  294.                 + "iconTextButton -edit -label \""
  295.                 + tabUIName($tabArray[$i])
  296.                 + "\" "
  297.                 + $tabChoiceButton);
  298.  
  299.         if ("allNodesTab" == $tabArray[$i]) menuItem -divider true;
  300.  
  301.         // Create the menu item
  302.         //
  303.         menuItem
  304.             -enableCommandRepeat false
  305.             -radioButton ($tabArray[$i] == $currentTab)
  306.             -label (tabUIName($tabArray[$i]))
  307.             -command $cmd;
  308.     }
  309. }
  310.  
  311. global proc createButtons(
  312.     string $classification,
  313.     string $as,
  314.     string $flag)
  315. {
  316.     //
  317.     // Description:
  318.     //    This procedure is called as the tabs of the render create bar UI are
  319.     //    being built. 
  320.     //    This procedure builds a button for each node type that is classified
  321.     //    according to $classification. The button command is configured to
  322.     //    create a node of that type using the $as and $flag arguments to
  323.     //    renderCreateBarCB().
  324.     //
  325.  
  326.     string $style = `optionVar -query renderCreateBarStyle`;
  327.  
  328.     int $dynamicsIsLicensed = `licenseCheck -mode edit -type fx`;
  329.     int $completeLicense = `licenseCheck -mode edit -type complete`;
  330.  
  331.     int $buttonWidth = 350;
  332.     int $buttonHeight = 34;
  333.  
  334.     if ($style == "iconsOnly")
  335.     {
  336.         $buttonWidth = 34;
  337.     }
  338.  
  339.     columnLayout -adjustableColumn true /* createButtonColumn */;
  340.  
  341.         string $nodes[] = `listNodeTypes $classification`;
  342.  
  343.         for ($type in $nodes) 
  344.         {
  345.             string $labelName = smallUIName($type);
  346.  
  347.             string $command = 
  348.                 ("renderCreateBarCB " 
  349.                     + $as 
  350.                     + " \""
  351.                     + $flag
  352.                     + "\" "
  353.                     + $type);
  354.  
  355.             string $buttonStyle, $annotation;
  356.             if ($style == "iconsAndText") {
  357.                 // Specify that the button should display icon and text, and
  358.                 // that it should not have an annotation
  359.                 //
  360.                 $buttonStyle = "iconAndTextHorizontal";
  361.                 $annotation = "";
  362.  
  363.             } else /* ($style == "iconsOnly") */ {
  364.                 $buttonStyle = "iconOnly";
  365.                 $annotation = $labelName;
  366.             } 
  367.  
  368.             nodeIconButton
  369.                 -width $buttonWidth
  370.                 -height $buttonHeight
  371.                 -label (" " + $labelName) 
  372.                 -image1 ("render_" + $type + ".xpm")
  373.                 -style      $buttonStyle
  374.                 -annotation $annotation 
  375.                 -command    $command
  376.                 ("createBar" + $type + "Button");
  377.  
  378.             if(        (!$dynamicsIsLicensed) 
  379.                 &&    (    ($type == "particleCloud") 
  380.                     ||  ($classification == "utility/particle"))) 
  381.             {
  382.                 // The node is a particle node, but the user does not have a
  383.                 // license for dynamics. We will disable the button for the 
  384.                 // node.
  385.                 //
  386.                 nodeIconButton 
  387.                     -edit
  388.                     -enable false 
  389.                     ("createBar" + $type + "Button");
  390.             } 
  391.  
  392.             if (    (!$completeLicense)
  393.                 &&    ($classification == "imageplane"))
  394.             {
  395.                 // The node is a image plane, but the user does not have a
  396.                 // license for complete. We will disable the button for the 
  397.                 // node.
  398.                 //
  399.                 nodeIconButton 
  400.                     -edit
  401.                     -enable false 
  402.                     ("createBar" + $type + "Button");
  403.             }
  404.         }
  405.  
  406.     setParent ..; // from createButtonColumn
  407. }
  408.  
  409. global proc renderCreateBarUICollapse(
  410.     string $frame,
  411.     string $button)
  412. {
  413.     //
  414.     // Description:
  415.     //    This method is called when the render create bar is being displayed in
  416.     //    icons only mode and the user has clicked on the collapse separator of a
  417.     //    section of buttons.
  418.     //    This method collapses or expands the specified frame (which contains 
  419.     //    the buttons directly below the collapse separator) and updates the icon
  420.     //    on the button appropriately.
  421.     //
  422.  
  423.     // Collapse or expand the frame layout
  424.     //
  425.     int $collapse = !(`frameLayout -query -collapse $frame`);
  426.  
  427.     frameLayout
  428.         -edit
  429.         -collapse $collapse
  430.         $frame;
  431.     
  432.     // Update the image on the button
  433.     //
  434.     string $image;
  435.  
  436.     if ($collapse)
  437.     {
  438.         $image = "closeBarHorizontal.xpm";
  439.     }
  440.     else
  441.     {
  442.         $image = "openBarHorizontal.xpm";
  443.     }
  444.  
  445.     iconTextButton
  446.         -edit
  447.         -image1 $image
  448.         $button;
  449. }
  450.  
  451. proc string createCollapseButton()
  452. {
  453.     //
  454.     // Description:
  455.     //    This procedure is called when the UI in a tab of the create bar is
  456.     //    being created.
  457.     //    This procedure creates a collapse separator button if and only if the
  458.     //    render create bar is in icons only mode. Otherwise this procedure does 
  459.     //    nothing.
  460.     //
  461.     // Returns:
  462.     //    The name of the button that is created.
  463.     //
  464.  
  465.     string $button;
  466.  
  467.     string $style = `optionVar -query renderCreateBarStyle`;
  468.  
  469.     if ($style == "iconsOnly")
  470.     {
  471.         $button = 
  472.             `iconTextButton
  473.                 -width 26
  474.                 -height 9
  475.                 -image1 "closeBarHorizontal.xpm"`;
  476.     }
  477.     
  478.     return $button;
  479. }
  480.  
  481. proc setCollapseButtonFrame(
  482.     string $button,
  483.     string $frame)
  484. {
  485.     //
  486.     // Description:
  487.     //    This procedure is called when the UI in a tab of the create bar is
  488.     //    being created.
  489.     //    This procedure associates the specified frame layout with the specified
  490.     //    collapse separator button. This allows the button to know which frame
  491.     //    to collapse/expand when pressed and what icon to initially display on
  492.     //    the button.
  493.     //
  494.  
  495.     string $style = `optionVar -query renderCreateBarStyle`;
  496.  
  497.     if ($style == "iconsOnly")
  498.     {
  499.         // Determine the initial image of the button from the current
  500.         // collapse/expand state of the frame layout
  501.         //
  502.         int $collapsed = `frameLayout -query -collapse $frame`;
  503.         string $annotation = `frameLayout -query -label $frame`;
  504.  
  505.         string $image;
  506.  
  507.         if ($collapsed)
  508.         {
  509.             $image = "closeBarHorizontal.xpm";
  510.         }
  511.         else
  512.         {
  513.             $image = "openBarHorizontal.xpm";
  514.         }
  515.  
  516.         // Set the image, annotation and command of the button
  517.         //
  518.         iconTextButton
  519.             -edit
  520.             -image1 $image
  521.             -annotation $annotation
  522.             -command
  523.                 ("renderCreateBarUICollapse " + $frame + " " + $button)
  524.             $button;
  525.     }
  526. }
  527.  
  528. global proc string createCollapseGroup(
  529.     string $label,
  530.     int    $labelVisible,
  531.     int    $borderVisible,
  532.     int    $collapsed)
  533. //
  534. //    Description:
  535. //        Create the collapse mechanism for a group of controls.
  536. //
  537. //        Currently, this is simply a collapsable frame Layout.
  538. //
  539. //    Arguments:
  540. //        label         - The label for the group.
  541. //
  542. //        labelVisible  - True if the label should be made visible.
  543. //
  544. //        borderVisible - True if the frame border should be made visible.
  545. //
  546. //        collapsed     - True if the group should be collapsed.
  547. //
  548. //    Returns:
  549. //        The full path name of the layout control created.
  550. //
  551. {
  552.     string $button, $frame;
  553.  
  554.     $button = createCollapseButton();
  555.     if(`about -mac`){
  556.         string $style = `optionVar -query renderCreateBarStyle`;
  557.  
  558.         if ($style == "iconsOnly"){
  559.             $frame = `frameLayout 
  560.             -label         $label
  561.             -borderVisible $borderVisible
  562.             -width            40
  563.             -labelVisible  $labelVisible
  564.             -collapsable   true 
  565.             -borderStyle   "etchedIn"
  566.             -marginWidth   0
  567.             -marginHeight  5
  568.             -collapse      $collapsed
  569.             `;
  570.         }else{
  571.             $frame = `frameLayout 
  572.             -label         $label
  573.             -borderVisible $borderVisible
  574.             -labelVisible  $labelVisible
  575.             -collapsable   true 
  576.             -borderStyle   "etchedIn"
  577.             -marginWidth   0
  578.             -marginHeight  5
  579.             -collapse      $collapsed
  580.             `;
  581.         }
  582.     }else{
  583.  
  584.         $frame = `frameLayout 
  585.             -label         $label
  586.             -borderVisible $borderVisible
  587.             -labelVisible  $labelVisible
  588.             -collapsable   true 
  589.             -borderStyle   "etchedIn"
  590.             -marginWidth   0
  591.             -marginHeight  5
  592.             -collapse      $collapsed
  593.             `;
  594.     }
  595.  
  596.     setCollapseButtonFrame($button, $frame);
  597.  
  598.     return $frame;
  599. }
  600.  
  601. proc string createSurfaceMaterials(int $labelVisible, int $borderVisible)
  602. //
  603. //    Description:
  604. //        Create the Surface Materials group.
  605. //
  606. //    Returns:
  607. //        The full path name of the layout control created.
  608. //
  609. {
  610.     return createCollapseGroup("Surface", $labelVisible, $borderVisible, false);
  611. }
  612.  
  613. proc string createVolumetricMaterials(int $labelVisible, int $borderVisible)
  614. //
  615. //    Description:
  616. //        Create the Volumetric Materials group.
  617. //
  618. //    Returns:
  619. //        The full path name of the layout control created.
  620. //
  621. {
  622.     return createCollapseGroup("Volumetric", $labelVisible, $borderVisible, true);
  623. }
  624.  
  625. proc string createDisplacementMaterials(int $labelVisible, int $borderVisible)
  626. //
  627. //    Description:
  628. //        Create the Displacement Materials group.
  629. //
  630. //    Returns:
  631. //        The full path name of the layout control created.
  632. //
  633. {
  634.     return createCollapseGroup("Displacement", $labelVisible, $borderVisible, true);
  635. }
  636.  
  637. proc createMaterialsTab()
  638. {
  639.     //
  640.     // Description:
  641.     //    This procedure is called as the UI is being created. 
  642.     //     This procedure creates the contents of the Materials tab.
  643.     //
  644.  
  645.     string $style = `optionVar -query renderCreateBarStyle`;
  646.  
  647.     int $borderVisible = true;
  648.     int $labelVisible = true;
  649.  
  650.     if ($style == "iconsOnly")
  651.     {
  652.         $borderVisible = false;
  653.         $labelVisible = false;
  654.     }
  655.  
  656.     scrollLayout materialsTab;
  657.  
  658.         columnLayout -adjustableColumn true /* materialsTabColumn */;
  659.  
  660.         createSurfaceMaterials($labelVisible, $borderVisible);
  661.         createButtons("shader/surface", "-asShader", "surfaceShader");
  662.         setParent ..;
  663.  
  664.         createVolumetricMaterials($labelVisible, $borderVisible);
  665.         createButtons("shader/volume", "-asShader", "volumeShader");
  666.         setParent ..;
  667.  
  668.         createDisplacementMaterials($labelVisible, $borderVisible);
  669.         createButtons("shader/displacement", "-asShader", "displacementShader");
  670.         setParent ..;
  671.  
  672.         setParent ..; // from materialsTabColumn
  673.  
  674.     setParent ..; // from materialsTab
  675. }
  676.  
  677. proc string create2DTextures(int $labelVisible, int $borderVisible)
  678. //
  679. //    Description:
  680. //        Create the 2D Textures group.
  681. //
  682. //    Returns:
  683. //        The full path name of the layout control created.
  684. //
  685. {
  686.     return createCollapseGroup("2D Textures", $labelVisible, $borderVisible, false);
  687. }
  688.  
  689. proc string create3DTextures(int $labelVisible, int $borderVisible)
  690. //
  691. //    Description:
  692. //        Create the 3D Textures group.
  693. //
  694. //    Returns:
  695. //        The full path name of the layout control created.
  696. //
  697. {
  698.     return createCollapseGroup("3D Textures", $labelVisible, $borderVisible, false);
  699. }
  700.  
  701. proc string createEnvironmentTextures(int $labelVisible, int $borderVisible)
  702. //
  703. //    Description:
  704. //        Create the Environment Textures group.
  705. //
  706. //    Returns:
  707. //        The full path name of the layout control created.
  708. //
  709. {
  710.     return createCollapseGroup("Env Textures", $labelVisible, $borderVisible, true);
  711. }
  712.  
  713. proc string createOtherTextures(int $labelVisible, int $borderVisible)
  714. //
  715. //    Description:
  716. //        Create the Other Textures group.
  717. //
  718. //    Returns:
  719. //        The full path name of the layout control created.
  720. //
  721. {
  722.     return createCollapseGroup("Other Textures", $labelVisible, $borderVisible, false);
  723. }
  724.  
  725. proc createTexturesTab()
  726. {
  727.     //
  728.     // Description:
  729.     //    This procedure is called as the UI is being created. 
  730.     //     This procedure creates the contents of the Textures tab.
  731.     //
  732.  
  733.     string $style = `optionVar -query renderCreateBarStyle`;
  734.  
  735.     int $borderVisible = true;
  736.     int $labelVisible = true;
  737.  
  738.     if ($style == "iconsOnly")
  739.     {
  740.         $borderVisible = false;
  741.         $labelVisible = false;
  742.     }
  743.  
  744.     scrollLayout texturesTab;
  745.  
  746.         columnLayout -adjustableColumn true /* texturesTabColumn */;
  747.  
  748.         create2DTextures($labelVisible, $borderVisible);
  749.  
  750.         columnLayout 
  751.             -adjustableColumn true 
  752.             /* texture2dOptionsAndButtonsColumn */;
  753.         radioCollection;
  754.  
  755.         radioButton -label "Normal" 
  756.             -align "left"
  757.             -onCommand ("optionVar "
  758.                 + "-stringValue create2dTextureType \"normal\";"
  759.                 + "refreshCreateNodeUI();")
  760.             normalRadioBtn;
  761.  
  762.         radioButton -label "As projection" 
  763.             -align "left"
  764.             -onCommand ("optionVar "
  765.                 + "-stringValue create2dTextureType \"projection\";"
  766.                 + "refreshCreateNodeUI();")
  767.             projectionRadioBtn;
  768.  
  769.         radioButton -label "As stencil" 
  770.             -align "left"
  771.             -onCommand ("optionVar "
  772.                 + "-stringValue create2dTextureType \"stencil\";"
  773.                 + "refreshCreateNodeUI();")
  774.             stencilRadioBtn;
  775.                 
  776.         if ($style == "iconsOnly") {
  777.             radioButton    -edit
  778.                 -label "N"
  779.                 -annotation "Normal"
  780.                 normalRadioBtn;
  781.             radioButton    -edit
  782.                 -label "P"
  783.                 -annotation "Projection"
  784.                 projectionRadioBtn;
  785.             radioButton    -edit
  786.                 -label "S"
  787.                 -annotation "Stencil"
  788.                 stencilRadioBtn;
  789.         }
  790.         
  791.         if (`optionVar -query create2dTextureType` == "normal")    {
  792.             radioButton -edit -select normalRadioBtn;
  793.  
  794.         } else if (`optionVar -query create2dTextureType` == "projection") {
  795.             radioButton -edit -select projectionRadioBtn;
  796.  
  797.         } else { // (`optionVar -query create2dTextureType` == "stencil")
  798.             radioButton -edit -select stencilRadioBtn;
  799.         }
  800.  
  801.         separator -style "none" -height 5;
  802.  
  803.         createButtons("texture/2d", "-as2DTexture", "");
  804.         setParent ..;
  805.         setParent ..;
  806.  
  807.         create3DTextures($labelVisible, $borderVisible);
  808.         createButtons("texture/3d", "-as3DTexture", "");
  809.         setParent ..;
  810.  
  811.         createEnvironmentTextures($labelVisible, $borderVisible);
  812.         createButtons("texture/environment", "-asEnvTexture", "");
  813.         setParent ..;
  814.  
  815.         createOtherTextures($labelVisible, $borderVisible);
  816.         createButtons("texture/other", "-asTexture", "");
  817.         setParent ..;
  818.  
  819.         setParent ..; // from texturesTabColumn
  820.     setParent ..; // from texturesTab
  821. }
  822.  
  823. proc string createLights(int $labelVisible, int $borderVisible)
  824. //
  825. //    Description:
  826. //        Create the Lights group.
  827. //
  828. //    Returns:
  829. //        The full path name of the layout control created.
  830. //
  831. {
  832.     return createCollapseGroup("Lights", $labelVisible, $borderVisible, false);
  833. }
  834.  
  835. proc createLightsTab()
  836. {
  837.     //
  838.     // Description:
  839.     //    This procedure is called as the UI is being created. 
  840.     //     This procedure creates the contents of the Lights tab.
  841.     //
  842.  
  843.     string $style = `optionVar -query renderCreateBarStyle`;
  844.  
  845.     int $borderVisible = true;
  846.     int $labelVisible = true;
  847.  
  848.     if ($style == "iconsOnly")
  849.     {
  850.         $borderVisible = false;
  851.         $labelVisible = false;
  852.     }
  853.  
  854.     scrollLayout lightsTab;
  855.  
  856.         columnLayout -adjustableColumn true /* lightsTabColumn */;
  857.  
  858.         createLights($labelVisible, $borderVisible);
  859.         createButtons("light", "-asLight", "");
  860.         setParent ..;
  861.  
  862.         setParent ..; // from lightsTabColumn
  863.  
  864.     setParent ..; // from lightsTab
  865. }
  866.  
  867. proc string createGeneralUtilities(int $labelVisible, int $borderVisible)
  868. //
  869. //    Description:
  870. //        Create the General Utilities group.
  871. //
  872. //    Returns:
  873. //        The full path name of the layout control created.
  874. //
  875. {
  876.     return createCollapseGroup("General Utilities", $labelVisible, $borderVisible, false);
  877. }
  878.  
  879. proc string createColorUtilities(int $labelVisible, int $borderVisible)
  880. //
  881. //    Description:
  882. //        Create the Color Utilities group.
  883. //
  884. //    Returns:
  885. //        The full path name of the layout control created.
  886. //
  887. {
  888.     return createCollapseGroup("Color Utilities", $labelVisible, $borderVisible, false);
  889. }
  890.  
  891. proc string createSwitchUtilities(int $labelVisible, int $borderVisible)
  892. //
  893. //    Description:
  894. //        Create the Switch Utilities group.
  895. //
  896. //    Returns:
  897. //        The full path name of the layout control created.
  898. //
  899. {
  900.     return createCollapseGroup("Switch Utilities", $labelVisible, $borderVisible, true);
  901. }
  902.  
  903. proc string createParticleUtilities(int $labelVisible, int $borderVisible)
  904. //
  905. //    Description:
  906. //        Create the Particle Utilities group.
  907. //
  908. //    Returns:
  909. //        The full path name of the layout control created.
  910. //
  911. {
  912.     return createCollapseGroup("Particle Utilities", $labelVisible, $borderVisible, true);
  913. }
  914.  
  915. proc string createImagePlanes(int $labelVisible, int $borderVisible)
  916. //
  917. //    Description:
  918. //        Create the Image Planes group.
  919. //
  920. //    Returns:
  921. //        The full path name of the layout control created.
  922. //
  923. {
  924.     return createCollapseGroup("Image Planes", $labelVisible, $borderVisible, true);
  925. }
  926.  
  927. proc string createGlow(int $labelVisible, int $borderVisible)
  928. //
  929. //    Description:
  930. //        Create the Glow group.
  931. //
  932. //    Returns:
  933. //        The full path name of the layout control created.
  934. //
  935. {
  936.     return createCollapseGroup("Glow", $labelVisible, $borderVisible, true);
  937. }
  938.  
  939. proc createUtilitiesTab()
  940. {
  941.     //
  942.     // Description:
  943.     //    This procedure is called as the UI is being created. 
  944.     //     This procedure creates the contents of the Utilities tab.
  945.     //
  946.  
  947.     string $style = `optionVar -query renderCreateBarStyle`;
  948.  
  949.     int $borderVisible = true;
  950.     int $labelVisible = true;
  951.  
  952.     if ($style == "iconsOnly")
  953.     {
  954.         $borderVisible = false;
  955.         $labelVisible = false;
  956.     }
  957.  
  958.     scrollLayout utilitiesTab;
  959.  
  960.         columnLayout -adjustableColumn true /* utilitiesTabColumn */;
  961.  
  962.         createGeneralUtilities($labelVisible, $borderVisible);
  963.         createButtons("utility/general", "-asUtility", "");
  964.         setParent ..;
  965.  
  966.         createColorUtilities($labelVisible, $borderVisible);
  967.         createButtons("utility/color", "-asUtility", "");
  968.         setParent ..;
  969.  
  970.         createSwitchUtilities($labelVisible, $borderVisible);
  971.         createButtons("utility/switch", "-asUtility", "");
  972.         setParent ..;
  973.  
  974.         createParticleUtilities($labelVisible, $borderVisible);
  975.         createButtons("utility/particle", "-asUtility", "");
  976.         setParent ..;
  977.  
  978.         createImagePlanes($labelVisible, $borderVisible);
  979.         createButtons("imageplane", "-asUtility", "");
  980.         setParent ..;
  981.  
  982.         createGlow($labelVisible, $borderVisible);
  983.         createButtons("postprocess/opticalFX", "-asPostProcess", "");
  984.         setParent ..;
  985.  
  986.         setParent ..; // from utilitiesTabColumn
  987.     setParent ..; // from utilitiesTab
  988. }
  989.  
  990. proc createAllNodesTab()
  991. //
  992. // Description:
  993. //    This procedure is called as the UI is being created. 
  994. //     This procedure creates the contents of the Utilities tab.
  995. //
  996. {
  997.     string $style = `optionVar -query renderCreateBarStyle`;
  998.  
  999.     int $borderVisible = true;
  1000.     int $labelVisible = true;
  1001.  
  1002.     if ($style == "iconsOnly")
  1003.     {
  1004.         $borderVisible = false;
  1005.         $labelVisible = false;
  1006.     }
  1007.  
  1008.     string $frame;
  1009.     string $button;
  1010.  
  1011.     scrollLayout allNodesTab;
  1012.  
  1013.         columnLayout -adjustableColumn true /* allNodesTabColumn */;
  1014.  
  1015.         //    Materials.
  1016.         //
  1017.         createSurfaceMaterials($labelVisible, $borderVisible);
  1018.         createButtons("shader/surface", "-asShader", "surfaceShader");
  1019.         setParent ..;
  1020.  
  1021.         createVolumetricMaterials($labelVisible, $borderVisible);
  1022.         createButtons("shader/volume", "-asShader", "volumeShader");
  1023.         setParent ..;
  1024.  
  1025.         createDisplacementMaterials($labelVisible, $borderVisible);
  1026.         createButtons("shader/displacement", "-asShader", "displacementShader");
  1027.         setParent ..;
  1028.  
  1029.         //    Textures.
  1030.         //
  1031.         create2DTextures($labelVisible, $borderVisible);
  1032.  
  1033.         columnLayout 
  1034.             -adjustableColumn true 
  1035.             /* texture2dOptionsAndButtonsColumn */;
  1036.  
  1037.         radioCollection;
  1038.  
  1039.         radioButton -label "Normal" 
  1040.             -align "left"
  1041.             -onCommand ("optionVar "
  1042.                 + "-stringValue create2dTextureType \"normal\";"
  1043.                 + "refreshCreateNodeUI();")
  1044.             normalRadioBtn2;
  1045.  
  1046.         radioButton -label "As Projection" 
  1047.             -align "left"
  1048.             -onCommand ("optionVar "
  1049.                 + "-stringValue create2dTextureType \"projection\";"
  1050.                 + "refreshCreateNodeUI();")
  1051.             projectionRadioBtn2;
  1052.  
  1053.         radioButton -label "As Stencil" 
  1054.             -align "left"
  1055.             -onCommand ("optionVar "
  1056.                 + "-stringValue create2dTextureType \"stencil\";"
  1057.                 + "refreshCreateNodeUI();")
  1058.             stencilRadioBtn2;
  1059.                 
  1060.         if ($style == "iconsOnly") {
  1061.             radioButton    -edit
  1062.                 -label "N"
  1063.                 -annotation "Normal"
  1064.                 normalRadioBtn2;
  1065.             radioButton    -edit
  1066.                 -label "P"
  1067.                 -annotation "Projection"
  1068.                 projectionRadioBtn2;
  1069.             radioButton    -edit
  1070.                 -label "S"
  1071.                 -annotation "Stencil"
  1072.                 stencilRadioBtn2;
  1073.         }
  1074.         
  1075.         if (`optionVar -query create2dTextureType` == "normal")    {
  1076.             radioButton -edit -select normalRadioBtn2;
  1077.  
  1078.         } else if (`optionVar -query create2dTextureType` == "projection") {
  1079.             radioButton -edit -select projectionRadioBtn2;
  1080.  
  1081.         } else { // (`optionVar -query create2dTextureType` == "stencil")
  1082.             radioButton -edit -select stencilRadioBtn2;
  1083.         }
  1084.  
  1085.         separator -style "none" -height 5;
  1086.  
  1087.         createButtons("texture/2d", "-as2DTexture", "");
  1088.         setParent ..;
  1089.         setParent ..;
  1090.  
  1091.         create3DTextures($labelVisible, $borderVisible);
  1092.         createButtons("texture/3d", "-as3DTexture", "");
  1093.         setParent ..;
  1094.  
  1095.         createEnvironmentTextures($labelVisible, $borderVisible);
  1096.         createButtons("texture/environment", "-asEnvTexture", "");
  1097.         setParent ..;
  1098.  
  1099.         createOtherTextures($labelVisible, $borderVisible);
  1100.         createButtons("texture/other", "-asTexture", "");
  1101.         setParent ..;
  1102.  
  1103.         //    Lights.
  1104.         //
  1105.         createLights($labelVisible, $borderVisible);
  1106.         createButtons("light", "-asLight", "");
  1107.         setParent ..;
  1108.  
  1109.         //    Utilities.
  1110.         //
  1111.         createGeneralUtilities($labelVisible, $borderVisible);
  1112.         createButtons("utility/general", "-asUtility", "");
  1113.         setParent ..;
  1114.  
  1115.         createColorUtilities($labelVisible, $borderVisible);
  1116.         createButtons("utility/color", "-asUtility", "");
  1117.         setParent ..;
  1118.  
  1119.         createSwitchUtilities($labelVisible, $borderVisible);
  1120.         createButtons("utility/switch", "-asUtility", "");
  1121.         setParent ..;
  1122.  
  1123.         createParticleUtilities($labelVisible, $borderVisible);
  1124.         createButtons("utility/particle", "-asUtility", "");
  1125.         setParent ..;
  1126.  
  1127.         createImagePlanes($labelVisible, $borderVisible);
  1128.         createButtons("imageplane", "-asUtility", "");
  1129.         setParent ..;
  1130.  
  1131.         createGlow($labelVisible, $borderVisible);
  1132.         createButtons("postprocess/opticalFX", "-asPostProcess", "");
  1133.         setParent ..;
  1134.         
  1135.         setParent ..; // from allNodesTabColumn
  1136.     setParent ..; // from allNodesTab
  1137. }
  1138.  
  1139. global proc renderCreateBarUIRefresh(
  1140.     string $renderCreateBarUI)
  1141. {
  1142.     //
  1143.     // Description:
  1144.     //    This procedure is called when the state of Maya has changed in a way
  1145.     //    that requires the create bar UI to be updated to reflect the new state.
  1146.     //    For now, the only thing this procedure does is ensure that the radio
  1147.     //    buttons in the textures tab are in sync with the option var dictating
  1148.     //    how 2d textures should be created (normal/projection/stencil).
  1149.     //
  1150.  
  1151.     // Remember the current parent so we can revert to it when we're done here.
  1152.     //
  1153.     string $oldParent = `setParent -query`;
  1154.     string $oldMenuParent = `setParent -menu -query`;
  1155.  
  1156.     // Ensure the proper radio button is selected in the 
  1157.     // normal/projection/stencil radio button collection in the textures tab.
  1158.     //
  1159.     setParent $renderCreateBarUI;
  1160.     setParent texturesTab;
  1161.  
  1162.     if (`optionVar -query create2dTextureType` == "normal")
  1163.     {
  1164.         radioButton -edit -select normalRadioBtn;
  1165.         radioButton -edit -select normalRadioBtn2;
  1166.  
  1167.     }
  1168.     else if (`optionVar -query create2dTextureType` == "projection")
  1169.     {
  1170.         radioButton -edit -select projectionRadioBtn;
  1171.         radioButton -edit -select projectionRadioBtn2;
  1172.  
  1173.     }
  1174.     else // (`optionVar -query create2dTextureType` == "stencil")
  1175.     {
  1176.         radioButton -edit -select stencilRadioBtn;
  1177.         radioButton -edit -select stencilRadioBtn2;
  1178.     }
  1179.  
  1180.     // Revert to the original parent.
  1181.     //
  1182.     setParent $oldParent;
  1183.     if ($oldMenuParent != "NONE") setParent -menu $oldMenuParent;
  1184. }
  1185.  
  1186. global proc string renderCreateBarUI(
  1187.     string $parentForm)
  1188. {
  1189.     //
  1190.     // Description:
  1191.     //    This procedure is called to build the UI on the left of the Hypershade
  1192.     //    panel which allows the user to create new render nodes.
  1193.     //
  1194.     // Returns:
  1195.     //    The name of the renderCreateBarUI that has been created. This name
  1196.     //    should be stored and used later as an argument to other procedures in
  1197.     //    this file which require it.
  1198.     //
  1199.  
  1200.     // Initialize optionVars if they do not yet exist
  1201.     //
  1202.     if (!`optionVar -exists renderCreateBarStyle`)
  1203.     {
  1204.         optionVar -stringValue renderCreateBarStyle "iconsAndText";
  1205.     }
  1206.     if (!`optionVar -exists renderCreateBarCurrentTab`)
  1207.     {
  1208.         optionVar -stringValue renderCreateBarCurrentTab "texturesTab";
  1209.     }
  1210.  
  1211.     string $style = `optionVar -query renderCreateBarStyle`;
  1212.  
  1213.     setParent $parentForm;
  1214.  
  1215.         string $renderCreateBarUI = `formLayout renderCreateBar`;
  1216.                 
  1217.             string $tabChoiceFrame = 
  1218.                 `frameLayout 
  1219.                     -labelVisible false 
  1220.                     -collapsable false
  1221.                     -borderStyle "out"`;
  1222.  
  1223.             string $tabChoiceButton = `iconTextButton
  1224.                 -image1     "shelfOptions.xpm"
  1225.                 -annotation "Choose which type of node to create"
  1226.                 -height     20`;
  1227.  
  1228.         setParent ..;
  1229.  
  1230.         if ($style == "iconsAndText") {
  1231.             iconTextButton -edit -style "iconAndTextHorizontal" $tabChoiceButton;
  1232.         } else /* ($style == "iconsOnly") */ {
  1233.             iconTextButton -edit -style "textOnly" $tabChoiceButton;
  1234.         }
  1235.  
  1236.         // Create the popup menu from which the user can choose the type of
  1237.         // nodes to create in the create bar
  1238.         //
  1239.         //    Put the popup menu on both the left and right mouse buttons.
  1240.         //    By putting on the right mouse button the user will get a 
  1241.         //    cursor change that indicates a popup menu is attached there.
  1242.         //
  1243.         string $menu = `popupMenu -button 1 -parent $tabChoiceButton`;
  1244.         menu 
  1245.             -edit 
  1246.             -postMenuCommand 
  1247.                 ("renderCreateBarUIBuildTabChoiceMenu "
  1248.                     + $tabChoiceButton
  1249.                     + " "
  1250.                     + $menu)
  1251.             $menu;
  1252.  
  1253.         $menu = `popupMenu -button 3 -parent $tabChoiceButton`;
  1254.         menu 
  1255.             -edit 
  1256.             -postMenuCommand 
  1257.                 ("renderCreateBarUIBuildTabChoiceMenu "
  1258.                     + $tabChoiceButton
  1259.                     + " "
  1260.                     + $menu)
  1261.             $menu;
  1262.  
  1263.         if (`about -os` == "nt")
  1264.         {
  1265.             frameLayout
  1266.                 -labelVisible false
  1267.                 -collapsable false
  1268.                 -borderStyle "in"
  1269.                 tabFrame;
  1270.         }
  1271.  
  1272.         // Create the tab layout which contains all of the node creation UI
  1273.         //
  1274.         tabLayout
  1275.             -tabsVisible false
  1276.             createBarTabLayout;
  1277.  
  1278.             // Define a template for scrollLayout which will be used when
  1279.             // creating the scrollLayouts inside of each of the following tabs.
  1280.             //
  1281.             if (!`uiTemplate -exists renderCreateBarTemplate`)
  1282.             {
  1283.                 uiTemplate renderCreateBarTemplate;
  1284.  
  1285.                 scrollLayout
  1286.                     -defineTemplate renderCreateBarTemplate
  1287.                     -horizontalScrollBarThickness 0
  1288.                     -verticalScrollBarThickness 16;
  1289.             }
  1290.  
  1291.             setUITemplate -pushTemplate renderCreateBarTemplate;
  1292.  
  1293.             createMaterialsTab();
  1294.             createTexturesTab();
  1295.             createLightsTab();
  1296.             createUtilitiesTab();
  1297.  
  1298.             int $showMentalRayCustomShaders =  0;
  1299.             int $mentalRayPluginLoaded =  0;
  1300.  
  1301.             if (`getenv MAYA_MRFM_SHOW_CUSTOM_SHADERS` == "1")
  1302.             {
  1303.                 $showMentalRayCustomShaders = 1;
  1304.             }
  1305.  
  1306.             if (`pluginInfo -query -loaded Mayatomr`)
  1307.             {
  1308.                 $mentalRayPluginLoaded = 1;
  1309.             }
  1310.             
  1311.             if ($showMentalRayCustomShaders && $mentalRayPluginLoaded)
  1312.             {
  1313.                 mrRenderCreateBar_CreateTab();
  1314.             }
  1315.  
  1316.             createAllNodesTab();
  1317.  
  1318.             setUITemplate -popTemplate;
  1319.  
  1320.             tabLayout
  1321.                 -edit
  1322.                 -tabLabel materialsTab "Materials"
  1323.                 -tabLabel texturesTab "Textures"
  1324.                 -tabLabel lightsTab "Lights"
  1325.                 -tabLabel utilitiesTab "Utilities"
  1326.                 -tabLabel allNodesTab "All Nodes"
  1327.                 createBarTabLayout;
  1328.  
  1329.             if ($showMentalRayCustomShaders && $mentalRayPluginLoaded)
  1330.             {
  1331.                 tabLayout
  1332.                     -edit
  1333.                     -tabLabel mrNodesTab "mental ray Nodes"
  1334.                     createBarTabLayout;
  1335.             }
  1336.  
  1337.             // Determine the current tab and set the contents of the create
  1338.             // bar and the label of the tab choice button to reflect it.
  1339.             //
  1340.             string $currentTab = 
  1341.                 (`optionVar -query renderCreateBarCurrentTab`);
  1342.  
  1343.             if (!`layout -exists $currentTab`)
  1344.             {
  1345.                 $currentTab = "materialsTab";
  1346.             }
  1347.  
  1348.             string $label = tabUIName($currentTab);
  1349.  
  1350.             iconTextButton
  1351.                 -edit
  1352.                 -label      $label
  1353.                 $tabChoiceButton;
  1354.  
  1355.             tabLayout
  1356.                 -edit
  1357.                 -selectTab $currentTab
  1358.                 createBarTabLayout;    
  1359.  
  1360.         setParent ..; // from createBarTabs
  1361.  
  1362.         if (`about -os` == "nt")
  1363.         {
  1364.             setParent ..; // from tabFrame
  1365.  
  1366.             formLayout
  1367.                 -edit
  1368.                 -af $tabChoiceFrame top 0
  1369.                 -an $tabChoiceFrame bottom
  1370.                 -af $tabChoiceFrame left 0
  1371.                 -af $tabChoiceFrame right 0
  1372.  
  1373.                 -ac tabFrame top 1 $tabChoiceFrame
  1374.                 -af tabFrame bottom 0
  1375.                 -af tabFrame left 0
  1376.                 -af tabFrame right 0
  1377.                 $renderCreateBarUI;
  1378.         }
  1379.         else
  1380.         {
  1381.             formLayout
  1382.                 -edit
  1383.                 -af $tabChoiceFrame top 0
  1384.                 -an $tabChoiceFrame bottom
  1385.                 -af $tabChoiceFrame left 0
  1386.                 -af $tabChoiceFrame right 0
  1387.  
  1388.                 -ac createBarTabLayout top 0 $tabChoiceFrame
  1389.                 -af createBarTabLayout bottom 0
  1390.                 -af createBarTabLayout left 0
  1391.                 -af createBarTabLayout right 0
  1392.                 $renderCreateBarUI;
  1393.         }
  1394.         
  1395.     setParent ..; // from $renderCreateBarUI
  1396.  
  1397.     formLayout
  1398.         -edit
  1399.         -af $renderCreateBarUI top 0
  1400.         -af $renderCreateBarUI bottom 0
  1401.         -af $renderCreateBarUI left 0
  1402.         -af $renderCreateBarUI right 0
  1403.         $parentForm;
  1404.     
  1405.     return $renderCreateBarUI;
  1406. }
  1407.